package com.night.icm.persistence.base.entity;

import com.night.icm.common.night_enum.DegreeType;
import com.night.icm.common.utils.SexType;
import com.night.icm.persistence.core.entity.User;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

/**
 * Teacher
 * 教师级以上权限：教务员
 * 教师角色：教务员ROLE_SENATOR、辅导员ROLE_INSTRUCTOR
 *
 * @author Liao ZhiYong
 * @date 2020/1/29
 */
@Entity
@Data
@Table(name = "night_icm_teacher")
public class Teacher {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "academy_id")
    private Academy academy;

    /**
     * 所属用户
     * 学生关联的系统登录账号，账号为学号，密码默认为6个9：999999
     */
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id")
    private User user;

    /**
     * 教师编号，也是用户的账号
     */
    @Column(name = "code", length = 50, nullable = false, unique = true)
    private String code;

    /**
     * 教师名称
     */
    @Column(name = "name", length = 100, nullable = false)
    private String name;

    /**
     * 是否教务员
     */
    @Column(name = "is_senator", nullable = false)
    private Boolean isSenator;

    /**
     * 是否辅导员
     */
    @Column(name = "is_instructor", nullable = false)
    private Boolean isInstructor;

    /**
     * 教师性别
     */
    @Column(name = "gender", nullable = false)
    @Enumerated(EnumType.STRING)
    private SexType gender;

    /**
     * 学历
     */
    @Column(name = "degree_type", length = 20)
    @Enumerated(EnumType.STRING)
    private DegreeType degreeType;

    /**
     * 出生日期
     */
    @Column(name = "birth_date")
    private Date birthDate;

    /**
     * 入职日期
     */
    @Column(name = "join_time")
    private Date joinTime;

    @Override
    public boolean equals(Object o) {
        return super.equals(o);
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}